﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DownloadInterface
{
    namespace DownloadError
    {
        public enum ErrorCode
        {
            DOWNLOAD_URL_INVALIDE,
            DOWNLOAD_FILENAME_INVALIDE,
            DOWNLOAD_NETWORK_DISCONNECTED,   //这里 可能是无网络连接，也可能是URL不存在
            DOWNLOAD_FILE_NOT_EXIST,
            //增加的
            DOWNLOAD_PATH_INVALIDE
        }

        public class ErrorCodeInterpreter
        {
            private static Dictionary<ErrorCode,string> errorInfo = new Dictionary<ErrorCode,string>();

            static ErrorCodeInterpreter()
            {
                errorInfo.Add(ErrorCode.DOWNLOAD_URL_INVALIDE, "下载地址无效");
                errorInfo.Add(ErrorCode.DOWNLOAD_FILENAME_INVALIDE, "保存文件名无效");
                errorInfo.Add(ErrorCode.DOWNLOAD_NETWORK_DISCONNECTED, "网络未连接，或者URL失效");
                errorInfo.Add(ErrorCode.DOWNLOAD_PATH_INVALIDE, "文件保存路径无效");
                errorInfo.Add(ErrorCode.DOWNLOAD_FILE_NOT_EXIST, "要删除的文件不存在");
            }

            public static string GetErrorDiscription(ErrorCode errorCode)
            {
                return errorInfo[errorCode];
            }
        }
    }
}
